/*
 * Copyright (c) 2011 Ball State University
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package edu.bsu.android.gtv.apps.bconnected.objects;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * Tutor object
 * @author Kyle Parker, University Computing Services
 */
public class Tutor {
	private String bsuID;
	private String buildingCode;
	private String buildingDesc;
	private String connectionTypeID;
	private String connectionTypeName;
	private String courseNum;
	private String department;
	private String discCode;
	private String emailAddress;
	private String error;
	private String firstName;
	private URL fullStoryURL;
	private String headline;
	private URL imageURL;
	private String lastName;
	private String latitude;
	private String loginGuid;
	private String longitude;
	private String middleName;
	private String namePrefix;
	private String nameSuffix;
	private String personType;
	private String phone;
	private String room;
	private boolean starred;
	private String tagline;
	private String titleRank;

	public String getBSUID() {		
		return bsuID;
	}
	public void setBSUID(String value) {
		this.bsuID = value.trim();
	}
	
	public String getBuildingCode() {		
		return buildingCode;
	}
	public void setBuildingCode(String value) {
		this.buildingCode = value.trim();
	}
	
	public String getBuildingDesc() {		
		return buildingDesc;
	}
	public void setBuildingDesc(String value) {
		this.buildingDesc = value.trim();
	}
	
	public String getConnectionTypeID() {		
		return connectionTypeID;
	}
	public void setConnectionTypeID(String value) {
		this.connectionTypeID = value.trim();
	}
	
	public String getConnectionTypeName() {		
		return connectionTypeName;
	}
	public void setConnectionTypeName(String value) {
		this.connectionTypeName = value.trim();
	}
	
	public String getCourseNum() {		
		return courseNum;
	}
	public void setCourseNum(String value) {
		this.courseNum = value.trim();
	}
	
	public String getDepartment() {		
		return department;
	}	
	public void setDepartment(String value) {
		this.department = value.trim();
	}
	
	public String getDisciplineCode() {		
		return discCode;
	}
	public void setDisciplineCode(String value)  {
		this.discCode = value.trim();
	}

	public String getEmailAddress() {		
		return emailAddress;
	}
	public void setEmailAddress(String value) {
		this.emailAddress = value.trim();
	}
	
	public String getError() {		
		return error;
	}
	public void setError(String value) {
		this.error = value.trim();
	}

	public String getFirstName() {		
		return firstName;
	}
	public void setFirstName(String value) {
		this.firstName = value.trim();
	}
	
	public URL getFullStoryURL() {
		return fullStoryURL;
	}	
	public void setFullStoryURL(String value) {
		try  {
			this.fullStoryURL = new URL(value);
		} catch (MalformedURLException e) {
			throw new RuntimeException(e);
		}
	}
	
	public String getHeadline() {		
		return headline;
	}
	public void setHeadline(String value) {
		this.headline = value.trim();
	}
	
	public URL getImageURL() {
		return imageURL;
	}	
	public void setImageURL(String value) {
		try {
			this.imageURL = new URL(value);
		} catch (MalformedURLException e) {
			this.imageURL = null;
		}
	}
	
	public String getLastName() {		
		return lastName;
	}
	public void setLastName(String value) {
		this.lastName = value.trim();
	}

	public String getLatitude() {
		return latitude;
	}
	public void setLatitude(String value) {
		this.latitude = value.trim();
	}

	public String getLoginGuid() {
		return loginGuid;
	}
	public void setLoginGuid(String value) {
		this.loginGuid = value.trim();
	}

	public String getLongitude() {
		return longitude;
	}
	public void setLongitude(String value) {
		this.longitude = value.trim();
	}

	public String getMiddleName() {		
		return middleName;
	}
	public void setMiddleName(String value) {
		this.middleName = value.trim();
	}

	public String getNamePrefix() {		
		return namePrefix;
	}
	public void setNamePrefix(String value) {
		this.namePrefix = value.trim();
	}

	public String getNameSuffix() {		
		return nameSuffix;
	}
	public void setNameSuffix(String value) {
		this.nameSuffix = value.trim();
	}

	public String getPersonType() {		
		return personType;
	}
	public void setPersonType(String value) {
		this.personType = value.trim();
	}

	public String getPhone() {		
		return phone;
	}
	public void setPhone(String value) {
		this.phone = value.trim();
	}

	public String getRoom() {		
		return room;
	}
	public void setRoom(String value) {
		this.room = value.trim();
	}

	public boolean getStarred() {		
		return starred;
	}
	public void setStarred(boolean value) {
		this.starred = value;
	}
	
	public String getTagline() {		
		return tagline;
	}
	public void setTagline(String value) {
		this.tagline = value.trim();
	}

	public String getTitleRank() {		
		return titleRank;
	}
	public void setTitleRank(String value) {
		this.titleRank = value.trim();
	}
	
	public Tutor copy() {
		Tutor copy = new Tutor();
		copy.bsuID = bsuID;
		copy.buildingCode = buildingCode;
		copy.buildingDesc = buildingDesc;
		copy.connectionTypeID = connectionTypeID;
		copy.connectionTypeName = connectionTypeName;
		copy.courseNum = courseNum;
		copy.department = department;
		copy.discCode = discCode;
		copy.emailAddress = emailAddress;
		copy.error = error;
		copy.firstName = firstName;
		copy.fullStoryURL = fullStoryURL;
		copy.headline = headline;
		copy.imageURL = imageURL;
		copy.lastName = lastName;
		copy.latitude = latitude;
		copy.loginGuid = loginGuid;
		copy.longitude = longitude;
		copy.middleName = middleName;
		copy.namePrefix = namePrefix;
		copy.nameSuffix = nameSuffix;
		copy.personType = personType;
		copy.phone = phone;
		copy.room = room;
		copy.starred = starred;
		copy.tagline = tagline;
		copy.titleRank = titleRank;
		return copy;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;

		result = prime * result + ((bsuID == null) ? 0 : bsuID.hashCode());
		result = prime * result + ((buildingCode == null) ? 0 : buildingCode.hashCode());
		result = prime * result + ((buildingDesc == null) ? 0 : buildingDesc.hashCode());
		result = prime * result + ((connectionTypeID == null) ? 0 : connectionTypeID.hashCode());
		result = prime * result + ((connectionTypeName == null) ? 0 : connectionTypeName.hashCode());
		result = prime * result + ((courseNum == null) ? 0 : courseNum.hashCode());
		result = prime * result + ((department == null) ? 0 : department.hashCode());
		result = prime * result + ((discCode == null) ? 0 : discCode.hashCode());
		result = prime * result + ((emailAddress == null) ? 0 : emailAddress.hashCode());
		result = prime * result + ((error == null) ? 0 : error.hashCode());
		result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
		result = prime * result + ((fullStoryURL == null) ? 0 : fullStoryURL.hashCode());
		result = prime * result + ((headline == null) ? 0 : headline.hashCode());
		result = prime * result + ((imageURL == null) ? 0 : imageURL.hashCode());
		result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
		result = prime * result + ((latitude == null) ? 0 : latitude.hashCode());
		result = prime * result + ((loginGuid == null) ? 0 : loginGuid.hashCode());
		result = prime * result + ((longitude == null) ? 0 : longitude.hashCode());
		result = prime * result + ((middleName == null) ? 0 : middleName.hashCode());
		result = prime * result + ((namePrefix == null) ? 0 : namePrefix.hashCode());
		result = prime * result + ((nameSuffix == null) ? 0 : nameSuffix.hashCode());
		result = prime * result + ((personType == null) ? 0 : personType.hashCode());
		result = prime * result + ((phone == null) ? 0 : phone.hashCode());
		result = prime * result + ((room == null) ? 0 : room.hashCode());
		result = prime * result + ((tagline == null) ? 0 : tagline.hashCode());
		result = prime * result + ((titleRank == null) ? 0 : titleRank.hashCode());
		return result;
	}
	
	@Override
	public boolean equals(Object obj)  {
		if (this == obj) { return true; }
		
		if (obj == null) { return false; }
		
		if (getClass() != obj.getClass()) { return false; }
		
		Tutor other = (Tutor) obj;
				
		if (bsuID == null) {
			if (other.bsuID != null) { return false; }
		} else if (!bsuID.equals(other.bsuID)) { return false; }

		if (buildingCode == null)  {
			if (other.buildingCode != null) { return false; }
		}  else if (!buildingCode.equals(other.buildingCode)) { return false; }
		
		if (buildingDesc == null) {
			if (other.buildingDesc != null) { return false; }
		}  else if (!buildingDesc.equals(other.buildingDesc)) { return false; }
		
		if (connectionTypeID == null) {
			if (other.connectionTypeID != null) { return false; }
		}  else if (!connectionTypeID.equals(other.connectionTypeID)) { return false; }
		
		if (connectionTypeName == null) {
			if (other.connectionTypeName != null) { return false; }
		} else if (!connectionTypeName.equals(other.connectionTypeName)) { return false; }
		
		if (courseNum == null) {
			if (other.courseNum != null) { return false; }
		} else if (!courseNum.equals(other.courseNum)) { return false; }
		
		if (department == null) {
			if (other.department != null) { return false; }
		} else if (!department.equals(other.department)) { return false; }
		
		if (discCode == null) {
			if (other.discCode != null) { return false; }
		} else if (!discCode.equals(other.discCode)) { return false; }
		
		if (emailAddress == null) {
			if (other.emailAddress != null) { return false; }
		} else if (!emailAddress.equals(other.emailAddress)) { return false; }
		
		if (error == null) {
			if (other.error != null) { return false; }
		} else if (!error.equals(other.error)) { return false; }
		
		if (firstName == null)  {
			if (other.firstName != null) { return false; }
		} else if (!firstName.equals(other.firstName)) { return false; }

		if (fullStoryURL == null) {
			if (other.fullStoryURL != null) return false;
		} else if (!fullStoryURL.equals(other.fullStoryURL)) return false;

		if (headline == null) {
			if (other.headline != null) return false;
		} else if (!headline.equals(other.headline)) return false;
		
		if (imageURL == null) {
			if (other.imageURL != null) { return false; }
		}  else if (!imageURL.equals(other.imageURL)) { return false; }
		
		if (lastName == null) {
			if (other.lastName != null) { return false; }
		} else if (!lastName.equals(other.lastName)) { return false; }
		
		if (latitude == null) {
			if (other.latitude != null) { return false; }
		} else if (!latitude.equals(other.latitude)) { return false; }
		
		if (loginGuid == null) {
			if (other.loginGuid != null) { return false; }
		} else if (!loginGuid.equals(other.loginGuid)) { return false; }
		
		if (longitude == null) {
			if (other.longitude != null) { return false; }
		} else if (!longitude.equals(other.longitude)) { return false; }
		
		if (middleName == null) {
			if (other.middleName != null) { return false; }
		} else if (!middleName.equals(other.middleName)) { return false; }
		
		if (namePrefix == null) {
			if (other.namePrefix != null) { return false; }
		} else if (!namePrefix.equals(other.namePrefix)) { return false; }
		
		if (nameSuffix == null) {
			if (other.nameSuffix != null) { return false; }
		} else if (!nameSuffix.equals(other.nameSuffix)) { return false; }
		
		if (personType == null) {
			if (other.personType != null) { return false; }
		} else if (!personType.equals(other.personType)) { return false; }
		
		if (phone == null) {
			if (other.phone != null) { return false; }
		} else if (!phone.equals(other.phone)) { return false; }
		
		if (room == null) {
			if (other.room != null) { return false; }
		} else if (!room.equals(other.room)) { return false; }

		if (tagline == null) {
			if (other.tagline != null) return false;
		} else if (!tagline.equals(other.tagline)) return false;
		
		if (titleRank == null) {
			if (other.titleRank != null) { return false; }
		}  else if (!titleRank.equals(other.titleRank)) { return false; }
		
		return true;
	}

	public int compareTo(Tutor another) {
		if (another == null) return 1;
		return another.bsuID.compareTo(bsuID);
	}
}
